#include <iostream>
#include <vector>

using namespace std;

vector<vector<int> > ans;
vector<int> path;
bool check[7] = { false };

void dfs(vector<int>& num)
{
	if (path.size() == num.size())
	{
		ans.push_back(path);
		return;
	}
	for (int i = 0; i < num.size(); i++)
	{
		if (check[i] == false)
		{
			check[i] = true;
			path.push_back(num[i]);
			dfs(num);
			path.pop_back();
			check[i] = false;
		}
	}
}
vector<vector<int> > permute(vector<int>& num)
{
	dfs(num);
	return ans;
}
int main()
{
	vector<vector<int> > ans;
	vector<int> v = { 1,2,3 };
	ans = permute(v);
	cout << "{";
	for (int i = 0; i < ans.size(); i++)
	{
		cout << " {";
		for (int j = 0; j < ans[0].size(); j++)
		{
			cout << ans[i][j] << ", ";
		}
		cout << "} ";
	}
	cout << "}";
	return 0;
}